#!/bin/bash
# posparm.sh - Using positional parameters

function cntparm
{

    # 这里的变量为传递给cntparm的变量，即局部变量
    echo '$0 = '$0
    echo '$1 = '$1
    echo '$2 = '$2
    echo '$3 = '$3
    echo -e "inside cntparm: $# parms:$*\n"

}

echo 'cntparm "$*":'    # 传给cntparm函数的参数为一个字符串
cntparm "$*"
echo 'cntparm "$@":'    # 传给cntparm函数的参数为和整体参数个数相等的字符串
cntparm "$@"

# -e将字符串中的\n解释为换行，如果没有-e，echo会在每行后面自动加上换行
echo -e "outside cntparm: $*\n"
echo -e "outside cntparm: $@\n"
